package biz.microplus.information.bean;

import biz.microplus.information.common.DateUtil;

import javax.persistence.Column;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;

/**
 * 会员数据模型
 */
@Entity
public class MemberBean extends BaseBean {

    public static final String ACTION_LEVEL = "1";
    public static final String ACTION_SUBSCRIPT = "2";

    public MemberBean() {
    }

    public MemberBean(int parentId) {
        this.parentId = parentId;
        this.userId = parentId;
        this.createdAt = DateUtil.getNowTimestamp();
    }

    /**
     * 标识
     */
    @Id
    private int id;
    /**
     * 账户ID
     */
    @Column(name = "parent_id")
    private int parentId;
    /**
     * 操作人ID
     */
    @Column(name = "user_id")
    private int userId;
    /**
     * 级别ID
     * 1一级会员9999元/年：可参与100万以下（含100万）的物资处置
     * 二级会员39999元/年：可参与500万以下（含500万）的物资处置；
     * 二级会员39999元/年：可参与500万以下（含500万）的物资处置；
     * 高级会员59999元/年：可参与5000万以下（含5000万）的物资处置；
     * 最高级会员至尊级会员89999元/年：可参与5000万以上的物资处置
     */
    private int levelId;

    /**
     * 级别名称
     */
    private String levelName;
    /**
     * 级别金额
     */
    private BigDecimal levelAmount;
    /**
     * 类别ID
     * 1黄金会员6999元/年 可定向选择关注10家钢铁客户
     * 2铂金19999元/年：可定向选择关注30家钢铁客户
     * 3钻石会员29999元/年：可定向选择关注50家钢铁客户
     * 4宝石会员59999元/年：可定向选择关注100家钢铁客户
     */
    @Column(name = "category_id")
    private int categoryId;
    /**
     * 类别名称
     */
    private String categoryName;
    /**
     * 类别限额
     */
    private int categoryAmount;
    /**
     * 会员编号
     */
    private String no;
    /**
     * 会员级别到期时间戳
     */
    @Column(name = "level_expire_at")
    private int levelExpireAt;
    /**
     * 会员类别到期时间戳
     */
    @Column(name = "category_expire_at")
    private int categoryExpireAt;
    /**
     * 创建时间戳
     */
    @Column(name = "created_at")
    private int createdAt;
    /**
     * 更新时间戳
     */
    @Column(name = "updated_at")
    private int updatedAt;
    /**
     * 删除时间戳
     */
    private int deletedAt;

    /**
     * 已关注钢铁厂数量
     */
    private int enterpriseCount;


    /**
     * 账户余额
     */
    private BigDecimal balance;
    /**
     * 冻结金额
     */
    private BigDecimal frozenBalance;




    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getParentId() {
        return parentId;
    }

    public void setParentId(int parentId) {
        this.parentId = parentId;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public int getLevelId() {
        return levelId;
    }

    public void setLevelId(int levelId) {
        this.levelId = levelId;
    }

    public int getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public int getLevelExpireAt() {
        return levelExpireAt;
    }

    public void setLevelExpireAt(int levelExpireAt) {
        this.levelExpireAt = levelExpireAt;
    }

    public int getCategoryExpireAt() {
        return categoryExpireAt;
    }

    public void setCategoryExpireAt(int categoryExpireAt) {
        this.categoryExpireAt = categoryExpireAt;
    }

    public int getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(int createdAt) {
        this.createdAt = createdAt;
    }

    public int getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(int updatedAt) {
        this.updatedAt = updatedAt;
    }

    public int getDeletedAt() {
        return deletedAt;
    }

    public void setDeletedAt(int deletedAt) {
        this.deletedAt = deletedAt;
    }

    public String getLevelName() {
        if (this.levelId == 1) {
            this.levelName = "一级会员";
        } else if (this.levelId == 2) {
            this.levelName = "二级会员";
        } else if (this.levelId == 3) {
            this.levelName = "三级会员";
        } else if (this.levelId == 4) {
            this.levelName = "高级级会员";
        } else if (this.levelId == 5) {
            this.levelName = "至尊级会员";
        }
        return levelName;
    }

    public void setLevelName(String levelName) {
        this.levelName = levelName;
    }

    public BigDecimal getLevelAmount() {
        if (this.levelId == 1) {
            this.levelAmount = new BigDecimal(1000000);
        } else if (this.levelId == 2) {
            this.levelAmount = new BigDecimal(5000000);
        } else if (this.levelId == 3) {
            this.levelAmount = new BigDecimal(10000000);
        } else if (this.levelId == 4) {
            this.levelAmount = new BigDecimal(5000000);
        } else if (this.levelId == 5) {
            this.levelAmount = new BigDecimal(999999999);
        }
        return levelAmount;
    }

    public void setLevelAmount(BigDecimal levelAmount) {
        this.levelAmount = levelAmount;
    }

    public String getCategoryName() {
        if (this.categoryId == 1) {
            this.categoryName = "黄金会员";
        } else if (this.categoryId == 2) {
            this.categoryName = "铂金会员";
        } else if (this.categoryId == 3) {
            this.categoryName = "钻石会员";
        } else if (this.categoryId == 4) {
            this.categoryName = "宝石会员";
        }
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public int getCategoryAmount() {
        if (this.categoryId == 1) {
            this.categoryAmount = 10;
        } else if (this.categoryId == 2) {
            this.categoryAmount = 30;
        } else if (this.categoryId == 3) {
            this.categoryAmount = 50;
        } else if (this.categoryId == 4) {
            this.categoryAmount = 100;
        }
        return categoryAmount;
    }

    public void setCategoryAmount(int categoryAmount) {
        this.categoryAmount = categoryAmount;
    }

    public int getEnterpriseCount() {
        return enterpriseCount;
    }

    public void setEnterpriseCount(int enterpriseCount) {
        this.enterpriseCount = enterpriseCount;
    }

    public BigDecimal getBalance() {
        return balance;
    }

    public void setBalance(BigDecimal balance) {
        this.balance = balance;
    }

    public BigDecimal getFrozenBalance() {
        return frozenBalance;
    }

    public void setFrozenBalance(BigDecimal frozenBalance) {
        this.frozenBalance = frozenBalance;
    }
}